<?php

use yii\grid\GridView;
use common\helpers\Html;

$this->title = '宿舍成员管理1';
$this->params['breadcrumbs'][] = ['label' => $this->title];

?>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">
                    <?= $this->title; ?>
                    <small></small>
                </h3>
                <div class="box-tools">
<!--                    --><?//= Html::create(['per/index','group'=>$hhh],'创建',[
//                        'data-toggle' => 'modal',
//                        'data-target' => '#ajaxModal',
//                    ]) ?>
                    <?= Html::linkButton(['ber/index','group'=>$hhh], '添加成员', [])?>
                </div>
            </div>
            <div class="box-body table-responsive">
                <?= GridView::widget([
                    'dataProvider' => $dataProvider,
                    'filterModel' => $searchModel,
                    // 重新定义分页样式
                    'tableOptions' => ['class' => 'table table-hover'],
                    'columns' => [
                        [
                            'class' => 'yii\grid\SerialColumn',
                        ],

                        [
                            'attribute' => 'cate.name',
                        ],
                        [
                            'attribute' => 'leader',
                            'value' => function($dataProvider) {
                                return $dataProvider->leader == 1 ? '是' : '否';
                            }
                        ],
                        [
                            'header' => "操作",
                            'class' => 'yii\grid\ActionColumn',
                            'template' => '{ajax-edit} {status} {destroy}{group}{recharge}',
                            'buttons' => [
                                'ajax-edit' => function ($url, $model, $key) {
                                    return Html::edit(['ajax-edit','id' => $model->id,], '编辑', [
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                },
                                'status' => function ($url, $model, $key) {
                                    return Html::status($model->status);
                                },
                                'destroy' => function ($url, $model, $key) {
                                    return Html::delete(['destroy', 'id' => $model->id]);
                                },
                                'group' => function ($url, $model, $key) {
                                    return Html::linkButton(['update', 'id' => $model->id], '设定组长', [
                                        'data-toggle' => 'modal',
                                        'data-target' => '#ajaxModal',
                                    ]);
                                },

                            ],
                        ],
                    ],
                ]); ?>
            </div>
        </div>
    </div>